
function openWinBox(URL,title,w,h,o,okval,cancelVal){ //弹出窗口
	if(!w) w=780;
	if(!h) h= $(window).height();
	if(!o) o=0.2;
	if(!okval) okval='确定';
	if(!cancelVal) cancelVal='关闭';
	var okbutton;
	if(okval==='NULL'){
		okbutton =false;
	}else{
		okbutton = function (iframe) {
			var form = iframe.document.getElementById('dosubmit').click();
			return false;
		}
	}
	art.dialog.open(URL, {
		title: title,
		width: w, 
		height: h,
		lock:true,
		opacity: o,
		
		ok: okbutton,
		okVal:okval,
		cancel: true,
		cancelVal:cancelVal
	})
}
	
//鼠标激活及失去焦点事件
$.fn.active = function(options) {  
	var defaults = {activeClass:'on'};
	var opt = $.extend(defaults, options);  
	this.each(function(){  
    	var obj=$(this);
		obj.focus(function(){ $(this).addClass(opt.activeClass);});
		obj.blur(function(){ $(this).removeClass(opt.activeClass);});
	});
};  
function checkInfo(id,msg,dom,text){ //表单验证提示
	text = text?text:'';
	$('#'+id).select();
	if(dom){
		$(dom).addClass('onError').html(msg);
	}else{
		$('#'+id).next('span.onShow').addClass('onError').html(msg);
	}
	setTimeout(function(){ $('#'+id).next('span').removeClass('onError').html(text);},2500);
}
function msg(content,icon,time,opacity){ //弹出提示窗口
	if(!time) time = 1.5;
	if(!opacity) opacity = 0;
	if(isNaN(icon)===false){
		switch (icon){
			case 0:icon='error';break;
			case 1:icon='succeed';break;
			case 2:icon='warning';break;
			default: icon='warning';
		}
	}
	art.dialog.through({
		time: time,
		icon: icon,
		lock:true,
		opacity:opacity,
		content: content
	});	
}
function closeWin(time){
	if(!time) time = 0;
	setTimeout("art.dialog.close()",time);	
}

function selectAll(obj,name){ //全选及反选
	var checkbox = $("input[name='"+name+"']");
	if(obj.checked==true){
		checkbox.each(function(){
			this.checked = true;
			$(this).parent().parent().addClass('new-focus');
		});
	}else{
		checkbox.each(function(){
			this.checked = false;
			$(this).parent().parent().removeClass('new-focus');
		});
	}
}
function selectThis(obj){ //单选
	if(obj.checked==true){
		obj.parentNode.parentNode.className = 'new-focus';
	}else{
		obj.parentNode.parentNode.className = '';
	}
}


function sound(sound){ 
	$('bgsound').attr('src','/Public/Media/'+sound+'.mp3');	
}

$(function(){
	$('.sub_pos').click(function(){
		var txt = $(this).html();
		var win = art.dialog.top;
		win.document.getElementById('sub_pos').innerHTML = " >> "+txt;
	})	

	$('.input-text').active();
	
})


/* left */
$(function(){
	$('#top_menu li').click(function(){
		var index = $('#top_menu li').index(this);
		$(this).addClass('on').siblings('li').removeClass('on');	
		$('.sub_menu').removeClass('on');
		$('#leftMain .sidebox').eq(index).show().siblings().hide();
		$('#leftMain .sidebox').eq(index).find('ul:first').find('li:first-child').addClass('on');
	})
	
	height = $(window).height()-150+'px';
	$('#rightMain').height(height);
	$('#openClose').height(height);
	$(window).resize(function(){
		h = $(this).height()-150+'px';
		$('#rightMain').height(h);	
		$('#openClose').height(h);	
	})
	
	$(".switchs").each(function(i){
		var ul = $(this).parent().next();
		$(this).click(
		function(){
			if(ul.is(':visible')){
				ul.hide();
				$(this).removeClass('on');
					}else{
				ul.show();
				$(this).addClass('on');
			}
		})
	});
	
	$('#openClose').toggle(
		function(){ 
			$(this).addClass('close');
			$('html').addClass('on');
			$('.left_menu').width(15);
			$('#Scroll').css({'padding':0,'width':0});
		},
		function(){ 
			$(this).removeClass('close');
			$('html').removeClass('on');
			$('.left_menu').width(145);
			$('#Scroll').attr('style','');
		}
	);
	
	$('#leftMain > .sidebox  li.sub_menu').click(function(){
		$('li.sub_menu').removeClass('on');
		$(this).addClass('on');	
		var txt = $(this).html();
		$('#sub_pos').html(" >> "+txt);
	})	
})
